PROJECTENGRAM

[REV] LBYARCH COMPREHENSIVE FINALS REVIEWER

Tags: #◇Computer Science #◇LBYARCH #◇Assembly #◇x86-64 #◇Verilog #◇Reviewer #◇Finals


LBYARCH Comprehensive Finals Reviewer

◇Overview

This reviewer synthesizes Computer Architecture and Organization Laboratory (LBYARCH). The curriculum comprises digital system modeling in Verilog HDL (combinational ALU design, testbenches with $monitor and $finish, structural vs behavioral syntax), x86-64 assembly programming using NASM, System V AMD64 ABI calling conventions, pointer and array memory addressing, floating-point scalar and SIMD vector operations (SSE/AVX: XMM/YMM registers), and interfacing C drivers with native x86-64 assembly kernels.


◇1. System V AMD64 ABI Calling Convention Matrix

RegisterRole / ABI SpecificationPreserved across Call? (Saved by)
RAX1st Return Value (integers, pointers)Caller-Saved (Scratch)
RDX2nd Return ValueCaller-Saved (Scratch)
RDI1st Function ArgumentCaller-Saved
RSI2nd Function ArgumentCaller-Saved
RDX3rd Function ArgumentCaller-Saved
RCX4th Function ArgumentCaller-Saved
R85th Function ArgumentCaller-Saved
R96th Function ArgumentCaller-Saved
XMM0–XMM7Floating-point arguments and return value (XMM0)Caller-Saved
RBX, RSP, RBP, R12–R15Callee-Saved RegistersCallee-Saved (Must restore before ret)

[!IMPORTANT] Stack Alignment Requirement
The System V AMD64 ABI mandates that the stack pointer RSP must be 16-byte aligned (RSP % 16 == 0) immediately prior to executing any call instruction! Because call pushes the 8-byte return address, inside the function prologue RSP % 16 == 8.


◇2. x86-64 Stack Frame Architecture


◇3. High-Yield Exam Checklist

  • Are the first 6 integer arguments passed in RDI, RSI, RDX, RCX, R8, R9? YES.
  • If a function modifies RBX, R12, R13, R14, or R15, must it push and pop them? YES (Callee-saved).
  • How is an array element arr[i] accessed in x86-64 when RDI = arr and RCX = i for 4-byte integers? [rdi + rcx*4].
  • In NASM, does mov eax, [rbx] dereference the memory address in RBX? YES (brackets mean dereference).
  • In Verilog, what simulator directive stops simulation? $finish;.

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

Under the System V AMD64 ABI, in which register does a C caller pass the third integer argument to an assembly function?

Q2

Which register must be explicitly preserved (pushed and popped) by an assembly function if it is modified during execution?

Q3

In x86-64 assembly, what does the instruction lea rax, [rdi + rsi*4 + 8] do?

Q4

If an assembly function calls printf, what condition must be satisfied regarding the stack pointer RSP prior to the call?

Q5

In Verilog HDL testbenches, which system task displays a formatted string in the console whenever any monitored variable changes value?

[REV] LBYARCH Comprehensive Finals Reviewer | PROJECT ENGRAM